package com.mongo.operation.data;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

public interface DataRepository extends MongoRepository<DataMongoObject, String> {

    /**
     * 通过token进行数据查询,非GridFS
     *
     * @param token
     * @return
     */
    DataMongoObject findByToken(String token);

    /**
     * 通过sourceName进行查询
     *
     * @param sourceName
     * @param pageable
     * @return
     */
    Page<DataMongoObject> findBySourceName(String sourceName, Pageable pageable);

    @Override
//    @Query(value = "{'data.updateTime':{'$gte':1546876800000}}")
    Page<DataMongoObject> findAll(Pageable pageable);

//    @Query(value = "{'requestArgs.website':?0}")
//    Page<DataMongoObject> findByRequestArsWebsite(String website, Pageable pageable);
}
